/**
 * <p>Copyright (c) 2017 深圳市鹏途交通科技有限公司 </p>
 * <p>		    All right reserved. 		     </p>
 * <p>项目名称 ： 	 深圳公路信息资源整合及国省检日常化监管管理        </p>
 * <p>创建者   :	詹春贤 
 * <p>描   述  :   路网服务-应急体系-应急保通-应急演练的数据管理  </p>
 * <p>最后修改 : $: 2017年8月29日-下午1:48:01 v 1.0.0	 Administrator   $ </p>
 * 
*/

package com.pengtu.gsj.service.impl.lwfw;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.dao.lwfw.EmergDrillDao;
import com.pengtu.gsj.entity.app.Attachment;
import com.pengtu.gsj.entity.lwfw.EmergDrill;
import com.pengtu.gsj.service.lwfw.EmergDrillService;
import com.pengtu.gsj.service.system.SystemManageService;

/**
 * 
 * EmergDrillServiceImpl
 * 
 * 2017年8月29日 下午1:48:01
 * 
 * @version 1.0.0
 * 
 */

@Service
@Transactional
public class EmergDrillServiceImpl implements EmergDrillService{

	@Autowired
	private EmergDrillDao emergDrillDao;
	@Autowired
	private SystemManageService systemManageService;
	
	@Override
	public void saveEmergDrill(EmergDrill emergDrill){
		emergDrillDao.save(emergDrill);
	}
	
	@Override
	public Page<EmergDrill> findEmergDrill(Page<EmergDrill> page, final QueryFilter queryFilter){
		return emergDrillDao.findPage(page, queryFilter);
	}
	
	@Override
	public EmergDrill getEmergDrillById(String id){
		return emergDrillDao.get(id);
	}
	
	@Override
	public void  delateEmergDrill(EmergDrill emergDrill){
		if(emergDrill.getAttachments() != null){
			for(Attachment attachment : emergDrill.getAttachments()){
				systemManageService.deleteAttachment(attachment);
			}
		}
		emergDrillDao.delete(emergDrill);
	}
}
